<template>
  <van-popup
    v-model:show="props.dateVisible"
    position="bottom"
    :overlay="true"
  >
    <van-datetime-picker
      cancel-button-text="取消"
      v-model="props.currentDate"
      type="date"
      title="选择年月日"
      @confirm="onConfirm"
      @cancel="onCancel"
      show-toolbar
      :min-date="minDate"
      :max-date="maxDate"
    />
  </van-popup>
</template>

<script setup lang="ts">
const emit = defineEmits(['closeDate', 'confirmDate'])
const props = defineProps({
  dateVisible: {
    type: Object,
    required: true
  },
  currentDate: {
    type: Object,
    required: true
  },
  maxDate: {
    type: Object,
    required: true
  },
  minDate: {
    type: Object,
    required: true
  }
})

const onCancel = async () => {
  emit('closeDate')
}
const onConfirm = async (val:any) => {
  emit('confirmDate', val)
}
</script>
